import type { App } from 'vue'

import * as components from '@/components'

export type AppUsePlugin = (app: App<Element>) => void

export const useComponents: AppUsePlugin = (app) => {
  Object.entries(components).forEach(([keyName, component]: any) => {
    if (component.install && typeof component.install === 'function') {
      app.use(component)
    } else {
      app.component(keyName || component.name, component)
    }
  })
}
